// 工具数据数组
  const tools = [
    {
      icon: "fas fa-user",
      title: "中文姓名生成器",
      description: "随机生成中文姓名，可用于游戏角色、写作素材等场景，包含常见姓氏和名字组合。(๑•̀ㅂ•́)و✧",
      emoji: "(๑•̀ㅂ•́)و✧",
      link: "https://www.996day.com/name.html",
      buttonText: "立即使用",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-video",
      title: "在线屏幕录制",
      description: "直接在浏览器中录制屏幕活动，支持全屏或指定标签页录制，无需安装任何软件。(●'◡'●)",
      emoji: "(●'◡'●)",
      link: "https://www.996day.com/record.html",
      buttonText: "开始录制",
      category: "video-tools",
      platformType: "web",
      launchDate: "2025-07-24"
    },
        {
      icon: "fas fa-qrcode",
      title: "二维码扫描器",
      description: "使用摄像头扫描二维码并快速打开链接，支持闪光灯、摄像头切换和图片识别，完全在浏览器中处理保护隐私。(づ｡◕‿‿◕｡)づ",
      emoji: "(づ｡◕‿‿◕｡)づ",
      link: "./qr-scanner.html",
      buttonText: "开始扫描",
      category: "daily-tools",
      platformType: "all",
      launchDate: "2025-10-20"
    },
    {
      "icon": "fas fa-microphone",
      "title": "快捷录音",
      "description": "直接在浏览器中录音，录音存储在本地保护隐私。支持移动端浏览器，提供WebM（推荐）和MP3格式下载。(｡･ω･｡)",
      emoji: "(｡･ω･｡)",
      "link": "https://www.996day.com/tape.html",
      "buttonText": "开始录音",
      category: "audio-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-palette",
      title: "颜色卡",
      description: "获取颜色或者进行颜色RGB/RGBA/HEX/HSL互转。ヾ(≧▽≦*)o",
      emoji: "ヾ(≧▽≦*)o",
      link: "https://www.996day.com/color.html",
      buttonText: "开始使用",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-compress",
      title: "图片压缩",
      description: "智能压缩JPG/PNG图片，最高可减少70%文件大小，保持图片质量无明显损失。(づ｡◕‿‿◕｡)づ",
      emoji: "(づ｡◕‿‿◕｡)づ",
      link: "https://www.996day.com/squoosh.html",
      buttonText: "压缩图片",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-exchange-alt",
      title: "图片格式转换",
      description: "支持JPG、PNG、WEBP、GIF等多种格式互相转换，保留EXIF信息。(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      emoji: "(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      link: "https://www.996day.com/imgFormat.html",
      buttonText: "转换图片",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-file-pdf",
      title: "图片转pdf",
      description: "支持JPG、PNG、WEBP、GIF等多种格式图片导出为pdf。(≧∇≦)ﾉ",
      emoji: "(≧∇≦)ﾉ",
      link: "https://www.996day.com/pdf.html",
      buttonText: "开始导出",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    
    {
      "icon": "fas fa-cut",
      "title": "媒体区域裁剪工具",
      "description": "支持视频和图片区域裁剪处理，视频可指定时长和区域，图片可精确裁剪 - 基于FFmpeg WebAssembly和Cropper.js 🎬",
      "emoji": "🎬",
      "link": "https://www.996day.com/mediaCrop.html",
      "buttonText": "立即裁剪",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-cut",
      title: "音视频时长剪辑",
      description: "在浏览器中直接剪辑音频和视频文件，支持MP3、MP4多种格式。(๑•̀ω•́)ノ",
      emoji: "(๑•̀ω•́)ノ",
      link: "https://www.996day.com/jj.html",
      buttonText: "开始剪辑",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-photo-film",
      title: "音视频截图",
      description: "在浏览器中直接截图视频文件，支持MP4多种格式。(✿◠‿◠)",
      emoji: "(✿◠‿◠)",
      link: "https://www.996day.com/screenshot.html",
      buttonText: "开始截图",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-sync",
      title: "音视频格式转换",
      description: "将音视频文件转换为不同格式，支持MP3、WAV、MP4、MOV等常用格式。(～￣▽￣)～",
      emoji: "(～￣▽￣)～",
      link: "https://www.996day.com/format.html",
      buttonText: "转换格式",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-object-group",
      title: "音视频合并",
      description: "将多个音频或视频文件合并为一个文件，支持调整顺序和添加过渡效果。(｡◕‿◕｡)",
      emoji: "(｡◕‿◕｡)",
      link: "https://www.996day.com/merge.html",
      buttonText: "合并文件",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-cut",
      title: "视频音频分离",
      description: "将视频文件中的音频和视频轨道分离，支持指定时间范围和多种格式输出。(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      emoji: "(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      link: "https://www.996day.com/split.html",
      buttonText: "开始分离",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-video",
      title: "视频播放器",
      description: "支持多选、M3U8直播、FLV流媒体及主流视频格式。(●ˇ∀ˇ●)",
      emoji: "(●ˇ∀ˇ●)",
      link: "https://www.996day.com/player.html",
      buttonText: "前往播放",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-music",
      title: "音频可视化播放器",
      description: "支持音频/视频播放，实时音频频谱可视化，80个频率条动态显示，暂停时缓慢归零动画效果。(◕‿◕)♪",
      emoji: "(◕‿◕)♪",
      link: "https://www.996day.com/audioVisualizer.html",
      buttonText: "开始播放",
      category: "audio-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-eraser",
      title: "视频水印去除",
      description: "智能去除视频中的水印，支持多种视频格式，可精确选择水印区域进行处理。(◕‿◕)✨",
      emoji: "(◕‿◕)✨",
      link: "https://www.996day.com/watermark.html",
      buttonText: "去除水印",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-plus-circle",
      title: "视频水印添加",
      description: "为视频添加文字或图片水印，支持多种水印样式、透明度调节、位置自定义，处理记录可预览下载。(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      emoji: "(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      link: "https://www.996day.com/addWatermark.html",
      buttonText: "添加水印",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-tree",
      title: "心灵树洞",
      description: "安全的情感倾诉空间，你的话语不会被保存，只会随风飘散在森林中。(｡◕‿◕｡)",
      emoji: "(｡◕‿◕｡)",
      link: "https://www.996day.com/su.html",
      buttonText: "进入树洞",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-table",
      title: "在线Excel编辑器",
      description: "功能强大的在线Excel编辑器，支持多工作表、公式计算、格式设置，可读取、编辑和保存Excel文件。(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      emoji: "(ﾉ◕ヮ◕)ﾉ*:･ﾟ✧",
      link: "https://www.996day.com/excel.html",
      buttonText: "开始编辑",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-edit",
      title: "Markdown编辑器",
      description: "在线编辑和预览Markdown文档，支持实时渲染、语法高亮、文件导入导出，完美的写作体验。📝✨",
      emoji: "📝✨",
      link: "https://www.996day.com/md.html",
      buttonText: "开始编辑",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-calendar-alt",
      title: "在线黄历",
      description: "传统农历查询工具，提供农历日期、节气、宜忌、节假日等传统文化信息，采用精美卡通设计。📅✨",
      emoji: "📅✨",
      link: "https://www.996day.com/calendar.html",
      buttonText: "查看黄历",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-icons",
      title: "ICO图标生成器",
      description: "在线透明ICO图标生成器，支持多种图片格式上传，一键生成多尺寸ICO文件，完美支持透明背景。🎨✨",
      emoji: "🎨✨",
      link: "https://www.996day.com/ico-generator.html",
      buttonText: "生成图标",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-file-pdf",
      title: "PDF合并工具",
      description: "将多个PDF文件合并为一个PDF文件，支持拖拽排序、预览页面，完全在浏览器中处理，保护文件隐私。📄✨",
      emoji: "📄✨",
      link: "https://www.996day.com/pdf-merge.html",
      buttonText: "合并PDF",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-desktop",
      title: "屏幕检测工具",
      description: "专业的显示器测试与校准工具，支持坏点检测、色彩测试、响应时间测试等多种屏幕检测功能。🖥️✨",
      emoji: "🖥️✨",
      link: "https://www.996day.com/screen-test.html",
      buttonText: "开始检测",
      category: "daily-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-thermometer-half",
      title: "健康环境监测",
      description: "专业的健康环境监测工具，支持噪音监测、光照检测、温度估算等功能，守护您的生活品质。🌡️✨",
      emoji: "🌡️✨",
      link: "https://www.996day.com/health-environment.html",
      buttonText: "开始监测",
      category: "daily-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-toolbox",
      title: "工具导航大全",
      description: "汇集各类实用工具的导航页面，包含系统工具、开发工具、设计软件、办公应用等80多个精选工具，一站式工具导航体验。🧰✨",
      emoji: "🧰✨",
      link: "https://www.996day.com/tools-navigation.html",
      buttonText: "浏览工具",
      category: "daily-tools",
      platformType: "all",
      launchDate: "2025-07-24"
    },
    {
      icon: "fas fa-exchange-alt",
      title: "视频音频替换",
      description: "使用FFmpeg.wasm在浏览器中替换视频的音频轨道，支持多种格式，完全本地处理保护隐私。🎬✨",
      emoji: "🎬✨",
      link: "https://www.996day.com/video-audio-replace.html",
      buttonText: "开始替换",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-08-22"
    },
    {
      icon: "fas fa-redo",
      title: "音频循环工具",
      description: "将音频文件循环指定次数，支持多种音频格式和质量设置，完全在浏览器中处理。🔄✨",
      emoji: "🔄✨",
      link: "https://www.996day.com/audio-loop.html",
      buttonText: "开始循环",
      category: "audio-tools",
      platformType: "all",
      launchDate: "2025-08-22"
    },
    {
      icon: "fas fa-layer-group",
      title: "多音频合成",
      description: "将多个音频文件合成为一个，支持串联和混合模式，完全在浏览器中处理。🎵✨",
      emoji: "🎵✨",
      link: "https://www.996day.com/audio-merge.html",
      buttonText: "开始合成",
      category: "audio-tools",
      platformType: "all",
      launchDate: "2025-08-22"
    },
    {
      icon: "fas fa-film",
      title: "多视频音频合并",
      description: "将多个视频与一个长音频合并，支持视频循环播放至指定时长，完全在浏览器中处理。🎬🎵",
      emoji: "🎬🎵",
      link: "https://www.996day.com/multi-video-merge.html",
      buttonText: "开始合并",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-08-22"
    },
    {
      icon: "fas fa-images",
      title: "图片转视频工具",
      description: "将图片转换为视频，支持多图片合成、过渡效果、滤镜效果，视频时长匹配音频时长，完全在浏览器中处理。🎨🎬",
      emoji: "🎨🎬",
      link: "./image-to-video.html",
      buttonText: "开始转换",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-08-27"
    },
    {
      icon: "fas fa-code",
      title: "图片Base64转换工具",
      description: "支持图片转Base64编码和Base64解码为图片，完全在浏览器中处理，保护隐私。支持JPG、PNG、GIF、WEBP等多种格式。🖼️💻",
      emoji: "🖼️💻",
      link: "./base64-converter.html",
      buttonText: "开始转换",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-08-28"
    },
    {
      icon: "fas fa-file-code",
      title: "在线JSON查看工具",
      description: "功能强大的JSON格式化、验证和可视化工具，支持文件上传和直接输入，提供树形结构展示、语法高亮、统计信息等功能。📄✨",
      emoji: "📄✨",
      link: "./json-viewer.html",
      buttonText: "查看JSON",
      category: "text-tools",
      platformType: "all",
      launchDate: "2025-08-28"
    },
    {
      icon: "fas fa-compress-alt",
      title: "视频压缩工具",
      description: "基于FFmpeg的高质量视频压缩处理，支持多种预设方案和自定义参数，适用于3分钟以内的短视频压缩。🗜️✨",
      emoji: "🗜️✨",
      link: "./video-compress.html",
      buttonText: "开始压缩",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-08-28"
    },
    {
      icon: "fas fa-eye",
      title: "OCR文字识别工具",
      description: "智能图片文字识别工具，支持中文识别，点击图片选择区域进行精准识别，完全在浏览器中处理保护隐私。📖✨",
      emoji: "📖✨",
      link: "./ocr.html",
      buttonText: "开始识别",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-08-29"
    },
    {
      icon: "fas fa-file-image",
      title: "视频转WebP动图",
      description: "将视频文件转换为高质量WebP动态图片，支持时长裁剪、质量调节、帧率设置，完全在浏览器中处理保护隐私。🎬✨",
      emoji: "🎬✨",
      link: "./video-to-webp.html",
      buttonText: "开始转换",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-08-29"
    },
    {
      icon: "fas fa-video",
      title: "视频字幕合成",
      description: "将LRC、SRT、ASS字幕文件合成到视频中，支持多种字幕格式和视频格式，完全在浏览器中处理保护隐私。🎬📝",
      emoji: "🎬📝",
      link: "./subtitle-generator.html",
      buttonText: "合成字幕",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-09-02"
    },
    {
      icon: "fas fa-scissors",
      title: "多视频编辑器",
      description: "专业的多视频编辑工具，支持视频播放、片段标记、精确切割、批量处理，提供类似专业视频编辑软件的界面体验。(◕‿◕)✂️",
      emoji: "(◕‿◕)✂️",
      link: "./multi-video-editor.html",
      buttonText: "开始编辑",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-09-04"
    },
    {
      icon: "fas fa-music",
      title: "BGM合成工具",
      description: "为视频添加完美的背景音乐，支持多音频文件混合、音量调节、时间控制，完全在浏览器中处理保护隐私。🎵✨",
      emoji: "🎵✨",
      link: "./bgm-composer.html",
      buttonText: "开始合成",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-09-08"
    },
    {
      icon: "fas fa-calendar-check",
      title: "保质期计算器",
      description: "智能计算食品保质期和到期日期，支持快捷天数选择、批量计算、结果导出，帮助您更好地管理食品安全。(◕‿◕)⏰",
      emoji: "(◕‿◕)⏰",
      link: "./expiry-calculator.html",
      buttonText: "开始计算",
      category: "daily-tools",
      platformType: "all",
      launchDate: "2025-09-08"
    },
    {
      icon: "fas fa-cut",
      title: "视频片段移除工具",
      description: "精确移除视频中的指定片段，支持鼠标长按范围选择、多片段标记、实时预览，完全在浏览器中处理保护隐私。(◕‿◕)✂️",
      emoji: "(◕‿◕)✂️",
      link: "./video-segment-remover.html",
      buttonText: "开始移除",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-09-11"
    },
    {
      icon: "fas fa-redo",
      title: "视频循环播放工具",
      description: "将单个视频文件循环播放指定次数，支持多种视频格式和质量设置，完全在浏览器中处理保护隐私。(◕‿◕)🔄",
      emoji: "(◕‿◕)🔄",
      link: "./video-merge-two.html",
      buttonText: "开始循环",
      category: "video-tools",
      platformType: "all",
      launchDate: "2025-09-22"
    },

    {
      icon: "fas fa-font",
      title: "文字转图片",
      description: "从剪贴板粘贴文字并保留原有格式，一键导出高清图片。(＾▽＾)",
      emoji: "(＾▽＾)",
      link: "./text-to-image.html",
      buttonText: "导出图片",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-10-29"
    },

    {
      icon: "fas fa-font",
      title: "多图片合并",
      description: "将多个图片文件合并为一个图片文件，支持多种图片格式和质量设置，完全在浏览器中处理保护隐私。(◕‿◕)✨",
      emoji: "(◕‿◕)✨",
      link: "./canvas-board.html",
      buttonText: "合并图片",
      category: "image-tools",
      platformType: "all",
      launchDate: "2025-10-29"
    },

  ];

  // 检测当前平台类型
  function detectPlatform() {
    const userAgent = navigator.userAgent.toLowerCase();
    const isMobile = /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera mini/i.test(userAgent);
    return isMobile ? 'mobile' : 'web';
  }

  // 当前平台类型
  const currentPlatform = detectPlatform();

  // 工具分类定义
  const categories = {
    'all': { name: '全部工具', icon: 'fas fa-th' },
    'latest': { name: '最新功能', icon: 'fas fa-star' },
    'text-tools': { name: '文本工具', icon: 'fas fa-font' },
    'image-tools': { name: '图片工具', icon: 'fas fa-image' },
    'video-tools': { name: '视频工具', icon: 'fas fa-video' },
    'audio-tools': { name: '音频工具', icon: 'fas fa-music' },
    'daily-tools': { name: '日常工具', icon: 'fas fa-home' }
  };

  // 当前选中的分类
  let currentCategory = 'all';
  // 当前搜索关键词
  let currentSearchTerm = '';

  // 筛选工具函数
  function filterTools(category, searchTerm = currentSearchTerm) {
    if (currentCategory === category && currentSearchTerm === searchTerm) return; // 如果筛选条件没有变化，不执行筛选
    
    currentCategory = category;
    currentSearchTerm = searchTerm;
    
    let filteredTools;
    if (category === 'all') {
      filteredTools = tools;
    } else if (category === 'latest') {
      // 筛选最近15天内发布的工具
      const currentDate = new Date();
      const fifteenDaysAgo = new Date(currentDate.getTime() - 15 * 24 * 60 * 60 * 1000);
      
      filteredTools = tools.filter(tool => {
        if (!tool.launchDate) return false;
        const launchDate = new Date(tool.launchDate);
        return launchDate >= fifteenDaysAgo;
      }).sort((a, b) => new Date(b.launchDate) - new Date(a.launchDate)); // 按发布日期降序排列
    } else {
      filteredTools = tools.filter(tool => tool.category === category);
    }
    
    // 根据平台类型筛选工具
    filteredTools = filteredTools.filter(tool => {
      if (!tool.platformType) return true; // 如果没有platformType字段，默认显示
      return tool.platformType === 'all' || tool.platformType === currentPlatform;
    });
    
    // 如果有搜索关键词，进一步筛选
    if (searchTerm.trim()) {
      filteredTools = filteredTools.filter(tool => 
        tool.title.toLowerCase().includes(searchTerm.toLowerCase()) ||
        tool.description.toLowerCase().includes(searchTerm.toLowerCase())
      );
    }
    
    const timelineTrack = document.querySelector("#timelineTrack");
    
    // 保存当前容器高度，防止抖动
    const currentHeight = timelineTrack.offsetHeight;
    timelineTrack.style.minHeight = currentHeight + 'px';
    
    // 获取当前所有工具卡片
    const currentSections = document.querySelectorAll('.tool-section');
    
    // 添加淡出动画
    currentSections.forEach((section, index) => {
      section.classList.add('filtering-out');
    });
    
    // 延迟渲染新工具，等待淡出动画完成
    setTimeout(() => {
      renderTools(filteredTools);
      updateCategoryButtons();
      
      // 重置容器最小高度
      setTimeout(() => {
        timelineTrack.style.minHeight = 'auto';
      }, 100);
      
      // 添加淡入动画
      const newSections = document.querySelectorAll('.tool-section');
      newSections.forEach((section, index) => {
        section.classList.add('filtering-in');
        setTimeout(() => {
          section.classList.remove('filtering-out', 'filtering-in');
        }, 400);
      });
    }, 300);
  }

  // 渲染工具函数
  function renderTools(toolsToRender) {
    const timelineTrack = document.querySelector("#timelineTrack");
    
    // 清空现有内容
    timelineTrack.innerHTML = "";
    
    // 使用DocumentFragment批量添加元素
    const trackFragment = document.createDocumentFragment();
    
    toolsToRender.forEach((tool, index) => {
      // 提取表情符号
      const emoji = tool.emoji;
      // 创建工具卡片
      const section = document.createElement("div");
      section.className = "tool-section";
      section.id = `tool-${index}`;
      section.setAttribute('data-category', tool.category);
      
      // 初始状态设为隐藏，准备淡入动画
      section.style.opacity = '0';
      section.style.transform = 'translateY(20px)';
      
      // 创建卡片HTML结构
      section.innerHTML = `
        <div class="tool-content-wrapper">
          <div class="tool-visual">
            <div class="tool-icon-bg"></div>
            <i class="${tool.icon} tool-icon-large"></i>
          </div>
          <div class="tool-details">
            <h3 data-emoji="${emoji}">${tool.title}</h3>
            <p>${tool.description}</p>
            <a href="${tool.link}" class="tool-link" target="_blank">${tool.buttonText}</a>
          </div>
        </div>
      `;
      
      // 添加到文档片段
      trackFragment.appendChild(section);
    });
    
    // 一次性添加到DOM
    timelineTrack.appendChild(trackFragment);
    
    // 重新初始化动画观察器
    initializeAnimations();
  }

  // 初始化动画效果
  function initializeAnimations() {
    const toolSections = document.querySelectorAll('.tool-section');
    
    // 为新渲染的工具卡片添加渐进式淡入动画
    toolSections.forEach((section, index) => {
      // 设置过渡效果
      section.style.transition = `opacity 0.4s ease ${index * 0.05}s, transform 0.4s ease ${index * 0.05}s`;
      
      // 延迟触发淡入动画
      setTimeout(() => {
        section.style.opacity = '1';
        section.style.transform = 'translateY(0)';
      }, 50 + index * 30);
    });
    
    // 添加进入视图时的动画观察器（用于滚动时的动画）
    const observer = new IntersectionObserver(
      (entries) => {
        entries.forEach((entry) => {
          if (entry.isIntersecting) {
            entry.target.classList.add('in-view');
          }
        });
      },
      { threshold: 0.1 }
    );
    
    toolSections.forEach((section) => {
      observer.observe(section);
    });
  }

  // 计算每个分类的工具数量
  function getCategoryCount(categoryKey) {
    // 先根据平台筛选工具
    const platformFilteredTools = tools.filter(tool => {
      return tool.platformType === 'all' || tool.platformType === currentPlatform;
    });
    
    if (categoryKey === 'all') {
      return platformFilteredTools.length;
    } else if (categoryKey === 'latest') {
      // 计算最近15天内发布的工具数量
      const currentDate = new Date();
      const fifteenDaysAgo = new Date(currentDate.getTime() - 15 * 24 * 60 * 60 * 1000);
      
      return platformFilteredTools.filter(tool => {
        if (!tool.launchDate) return false;
        const launchDate = new Date(tool.launchDate);
        return launchDate >= fifteenDaysAgo;
      }).length;
    }
    return platformFilteredTools.filter(tool => tool.category === categoryKey).length;
  }

  // 生成分类导航
  function generateCategoryNavigation() {
    const categoryNav = document.querySelector('.tool-categories ul');
    if (!categoryNav) return;
    
    categoryNav.innerHTML = '';
    
    Object.keys(categories).forEach(categoryKey => {
      const category = categories[categoryKey];
      const count = getCategoryCount(categoryKey);
      const li = document.createElement('li');
      const a = document.createElement('a');
      
      a.href = '#';
      a.className = 'category-btn';
      a.setAttribute('data-category', categoryKey);
      a.innerHTML = `<i class="${category.icon}"></i> ${category.name} <span class="category-count">${count}</span>`;
      
      if (categoryKey === currentCategory) {
        a.classList.add('active');
      }
      
      a.addEventListener('click', (e) => {
        e.preventDefault();
        filterTools(categoryKey, currentSearchTerm);
      });
      
      li.appendChild(a);
      categoryNav.appendChild(li);
    });
  }

  // 更新分类按钮状态
  function updateCategoryButtons() {
    const categoryBtns = document.querySelectorAll('.category-btn');
    categoryBtns.forEach(btn => {
      btn.classList.remove('active');
      if (btn.getAttribute('data-category') === currentCategory) {
        btn.classList.add('active');
      }
    });
  }

  // 搜索功能
  function initializeSearch() {
    const searchInput = document.getElementById('toolSearch');
    if (!searchInput) return;
    
    let searchTimeout;
    
    searchInput.addEventListener('input', function(e) {
      const searchTerm = e.target.value;
      
      // 防抖处理，避免频繁搜索
      clearTimeout(searchTimeout);
      searchTimeout = setTimeout(() => {
        filterTools(currentCategory, searchTerm);
      }, 300);
    });
    
    // 清空搜索框时重置
    searchInput.addEventListener('keydown', function(e) {
      if (e.key === 'Escape') {
        searchInput.value = '';
        filterTools(currentCategory, '');
        searchInput.blur();
      }
    });
  }

  // 动态生成工具网格
  document.addEventListener("DOMContentLoaded", function() {
    // 生成分类导航
    generateCategoryNavigation();
    
    // 初始化搜索功能
    initializeSearch();
    
    // 初始渲染所有工具
    renderTools(tools);
    

  });
